package com.ky.tms.controller;


import com.ky.tms.entity.FixedAssets;
import com.ky.tms.entity.FixedAssetsLog;
import com.ky.tms.exception.PredictableException;
import com.ky.tms.service.IFixedAssetsService;
import com.ky.tms.util.CommonResult;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author chengkaimao
 * @since 2020-07-21
 */
@RestController
@RequestMapping("/tms/fixed-assets")
public class FixedAssetsController {

    @Autowired
    private IFixedAssetsService iFixedAssetsService;

    @ApiOperation("车辆类型数据分页")
    @GetMapping("page")
    public CommonResult page(FixedAssets assets, @RequestParam Long pageSize, @RequestParam Long current){
        return CommonResult.buildSuccess(iFixedAssetsService.page(assets, pageSize, current));
    }

    @ApiOperation("创建固定资产")
    @PostMapping
    public CommonResult add(@RequestBody FixedAssets fixedAssets) throws PredictableException {
        iFixedAssetsService.add(fixedAssets);
        return CommonResult.buildSuccess(null);
    }

    @ApiOperation("修改固定资产")
    @PutMapping
    public CommonResult update(@RequestBody FixedAssets fixedAssets) throws PredictableException {
        iFixedAssetsService.update(fixedAssets);
        return CommonResult.buildSuccess(null);
    }

    @ApiOperation("删除固定资产")
    @DeleteMapping
    public CommonResult delete(@RequestBody FixedAssets fixedAssets) throws PredictableException {
        iFixedAssetsService.del(fixedAssets);
        return CommonResult.buildSuccess(null);
    }

    @ApiOperation("信用记录")
    @PostMapping("logs")
    public CommonResult logs(@RequestBody FixedAssetsLog fixedAssetsLog) throws PredictableException {
        iFixedAssetsService.logs(fixedAssetsLog);
        return CommonResult.buildSuccess(null);
    }

    @PostMapping("imgs")
    @ApiOperation("上传照片")
    public CommonResult imgs(@RequestBody FixedAssets fixedAssets) throws PredictableException {
        iFixedAssetsService.imgs(fixedAssets);
        return CommonResult.buildSuccess(null);
    }

}
